package com.base.api.controller.commodityClassify;

import com.base.api.dto.commodityClassify.CommodityClassifySearchDTO;
import com.base.api.service.commodityClassify.CommodityClassifyApiService;
import com.base.log.WebLog;
import com.base.api.dto.commodityClassify.CommodityClassifyListDTO;
import com.base.result.ResponseResult;
import com.base.self.entity.CommodityClassify;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

@RestController
@Slf4j
@RequestMapping("/api/commodityClassify")
@Api(tags = "商品分类")
public class CommodityClassifyApiController {

    private final CommodityClassifyApiService commodityClassifyApiService;

    public CommodityClassifyApiController(CommodityClassifyApiService commodityClassifyApiService) {
        this.commodityClassifyApiService = commodityClassifyApiService;
    }

    @ApiOperation(value="商品分类查询")
    @PostMapping(value = "/commodityClassifyList", produces = "application/json;charset=UTF-8")
    @Validated
    @ApiResponses({
            @ApiResponse(code = 200, message = "OK", response = CommodityClassify.class),
    })
    @WebLog
    public ResponseResult commodityClassifyList(final @Valid CommodityClassifyListDTO commodityClassifyListDTO){
        return commodityClassifyApiService.commodityClassifyList(commodityClassifyListDTO);
    }

    @ApiOperation(value="商品分类搜索")
    @PostMapping(value = "/commodityClassifySearch", produces = "application/json;charset=UTF-8")
    @Validated
    @WebLog
    @ApiResponses({
            @ApiResponse(code = 200, message = "OK", response = CommodityClassify.class),
    })
    public ResponseResult commodityClassifySearch(final @Valid CommodityClassifySearchDTO commodityClassifySearchDTO){
        return commodityClassifyApiService.commodityClassifySearch(commodityClassifySearchDTO);
    }
}
